package controller;

import java.io.IOException;
import java.util.Locale;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.jf.annotations.ControllerJF;
import br.com.jf.annotations.HttpServletRequestJF;
import br.com.jf.annotations.HttpServletResponseJF;
import br.com.jf.annotations.InjectJF;
import br.com.jf.annotations.MethodJF;
import br.com.jf.annotations.RequestTypeJF;
import br.com.jf.annotations.ScopeTypeJF;
import br.com.jf.constants.RequestType;
import br.com.jf.constants.ScopeType;
import br.com.jf.utils.UserLocale;

@ControllerJF(urlPattern = "locale")
@ScopeTypeJF(scope=ScopeType.NONE)
public class LocaleController {

	@InjectJF
	private UserLocale userLocale;
	
	
	@MethodJF
	@RequestTypeJF(method=RequestType.GET,name="alterarLocaleUs")
	public String alterarLocaleUs(@HttpServletRequestJF HttpServletRequest request, @HttpServletResponseJF HttpServletResponse response) throws ServletException, IOException{

		userLocale.setLocale(Locale.ENGLISH);
		
		
		return "home.jsp";
	}
	
	@MethodJF
	@RequestTypeJF(method=RequestType.GET,name="alterarLocaleBr")
	public String alterarLocaleBr(@HttpServletRequestJF HttpServletRequest request, @HttpServletResponseJF HttpServletResponse response) throws ServletException, IOException{

		userLocale.setLocale(new Locale("pt","BR"));
		
		
		return "home.jsp";
	}
	
}
